﻿using System.Collections.Generic;
using System.Web.Routing;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace ScoutNET.Helpers
{
    public static class ActionLinkHtmlHelper
    {
        public static MvcHtmlString ActionLinkHtml(this HtmlHelper htmlHelper, string linkHtml, string actionName)
        {
            return ActionLinkHtml(htmlHelper, linkHtml, actionName, new RouteValueDictionary(), new RouteValueDictionary());
        }

        public static MvcHtmlString ActionLinkHtml(this HtmlHelper htmlHelper, string linkHtml, string actionName, object routeValues)
        {
            return ActionLinkHtml(htmlHelper, linkHtml, actionName, new RouteValueDictionary(routeValues), new RouteValueDictionary());
        }

        public static MvcHtmlString ActionLinkHtml(this HtmlHelper htmlHelper, string linkHtml, string actionName, object routeValues, object htmlAttributes)
        {
            return ActionLinkHtml(htmlHelper, linkHtml, actionName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes));
        }

        public static MvcHtmlString ActionLinkHtml(this HtmlHelper htmlHelper, string linkHtml, string actionName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)
        {
            string actionLink = LinkExtensions.ActionLink(htmlHelper, "__HTML_PLACEHOLDER__", actionName, routeValues, htmlAttributes).ToHtmlString();
            actionLink = actionLink.Replace("__HTML_PLACEHOLDER__", linkHtml);

            return MvcHtmlString.Create(actionLink);
        }
    }
}
